package xin.yangshuai.fastjson01.hello;

import com.alibaba.fastjson.JSON;

/**
 * Person
 *
 * @author shuai
 * @date 2021/3/23
 */
public class Person {

    @MyParamName(names = {
            @NameEle(id = "ln", value = "i_d"),
            @NameEle(id = "jl", value = "_id")})
    private String id;

    @MyParamName("NAME")
    private String name;

    private String age;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Person person = new Person();
        person.setAge("18");
        person.setId("001");
        person.setName("张三");

        String s = JSON.toJSONString(person, new MyNameFilter("jl"));
        System.out.println(s);

        String s1 = JSON.toJSONString(person, new MyNameFilter("ln"));
        System.out.println(s1);
    }
}
